package com.yuhang.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuhang.entity.BillBean;
import com.yuhang.entity.HyBill;
import com.yuhang.mapper.HyBillMapper;
import com.yuhang.service.HyBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yuhang
 * @since 2021-03-11
 */
@Service
public class HyBillServiceImpl extends ServiceImpl<HyBillMapper, HyBill> implements HyBillService {

    @Autowired
    private HyBillMapper hyBillMapper;

    @Override
    public IPage<HyBill> selectByPage(int pageNum, int pageSize,String likename) {
        Page<HyBill> page = new Page(pageNum,pageSize);
        QueryWrapper<HyBill> qw = new QueryWrapper();
        if(likename!=null&&!likename.equals("")){
            qw.like("user_name",likename);
        }
        IPage<HyBill> hyBillIPage = hyBillMapper.selectPage(page,qw);
        return hyBillIPage;
    }

    @Override
    public IPage<HyBill> selectByPage(int pageNum, int pageSize, int userid) {
        Page<HyBill> page = new Page(pageNum,pageSize);
        QueryWrapper<HyBill> qw = new QueryWrapper();
        qw.eq("user_id",userid);
        IPage<HyBill> hyBillIPage = hyBillMapper.selectPage(page,qw);
        return hyBillIPage;
    }

    @Override
    public List<BillBean> selectOrderByBillType() {
        return hyBillMapper.selectOrderByBillType();
    }

    @Override
    public List<BillBean> selectOrderBy() {
        return hyBillMapper.selectOrderBy();
    }

    @Override
    public List<BillBean> selectUserOrderByBillType(int id) {
        return hyBillMapper.selectUserOrderByBillType(id);
    }

    @Override
    public List<BillBean> selectUserOrderBy(int id) {
        return hyBillMapper.selectUserOrderBy(id);
    }

}
